<?
 Prado::using('System.Web.UI.ActiveControls.*'); 
 
 class HomeUser extends TPage
 {
	public $id = -1;
 
	public function onInit($param)
    {	
    	
		$this->id = $this->Request['id'];
		
		if(!$this->IsPostBack)  // if the page is requested the first time
		{
			$this->showCreateBookHint();
		}
		
			
	}
	

	
	public function showCreateBookHint()
	{
		if(!$this->isNavigatedUserSameAsOwner()) // for viewer, just show normal text
			$this->generalAboutBook->Visible = true;
			
			
		if($this->HasBook())
		{ // Show normal Text
			$this->generalAboutBook->Visible = true;
		}
		else
		{ // Show hint, how to create a new book
			$this->hintCreateBook->Visible = true;
		}
	}
	
	public function isNavigatedUserSameAsOwner()
	{
		return $this->id == $this->user->ID;
	}
	
	public function HasBook()
	{
		$count = BookIDRecord::finder()->count('user_id = ?',$this->id);
		
		return $count > 0;
	}
 }
 ?>